package authorization;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.cht.sys.CommonUtil;
import com.cht.sys.LDAP;

public class hasAuth extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public hasAuth() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding( "UTF-8" );
		response.setCharacterEncoding( "UTF-8" );
		response.setContentType("application/text");
		final String employeeno = request.getParameter("val");
		String res = CommonUtil.hasAuth(employeeno, topsJNDI);
		CommonUtil.doInvalidateSession(request);
		if ( res != null ) {
			res = res.trim();
		} else {
			res = "";
		}
		
		response.getWriter().write( res );
	}

}
